package com.bml.architect.springboot.config;

import com.bml.architect.springboot.utils.Constants;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 路由模式
 */
@Configuration
public class DirectConfig {


    @Bean
    public Queue directQ1() {
        return new Queue(Constants.DIRECT_QUEUE1);
    }

    @Bean
    public Queue directQ2() {
        return new Queue(Constants.DIRECT_QUEUE2);
    }

    @Bean
    public DirectExchange directExchange() {

        return new DirectExchange(Constants.DIRECT_EXCHANGE);
    }

    @Bean
    public Binding bindingDirectQ1() {
        return BindingBuilder.bind(directQ1()).to(directExchange()).with("d1.1");
    }

    @Bean
    public Binding bindingDirectQ2() {
        return BindingBuilder.bind(directQ2()).to(directExchange()).with("d2.1");
    }


}
